﻿using System;
using System.Runtime.Serialization;

namespace OpenWaves.EPiServer.BrightcoveVideoCloudProperty
{
    [DataContract]
    public class DataTimeExtensions
    {
        public static DateTime DateFromUnix(string value)
        {
            return new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(double.Parse(((object)value).ToString()) / 1000.0);
        }

        public static string DateToUnix(DateTime value)
        {
            return (value - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalSeconds.ToString();
        }
    }
}